{
    let oTxt = document.querySelector('.txt')
    let oBtn = document.querySelector('.submit')
    let oList = document.querySelector('.list')
    let oImg = document.querySelector('.text img')
    let oTime = oList.querySelector('.time')
    
    var now = new Date()
    var year = now.getFullYear()
    var month = now.getMonth() + 1
    var day = now.getDate()
    var h = now.getHours()
    var m = now.getMinutes()
    var s = now.getSeconds()

    // function getData(){
    //     ajax({
    //         url:'../server/list.php',
    //         type:'get',
    //         data:{
    //             num:1,
    //             limit:10,
    //             txt:''
    //         },
    //         success(res) {
    //             let json = JSON.parse(res)
    //             json.data.forEach(ele => {
    //                 oList.innerHTML += `
    //                     <li>
    //                         <img src="${ele.goods_small_logo}" alt="">
    //                         <p>${ele.goods_name}</p>
    //                         <span class="return">-> 回复</span>
    //                         <span class="delete">X 删除</span>
    //                         <span class="time">${year + '年' + month + '月' + day + '日' + toDou(h) + ':' + toDou(m) + ':' + toDou(s)}</span>
    //                         <b>${oTxt.value}</b>
    //                     </li>
    //                 `
    //             })
    //         }
    //     })
    // }
    // oBtn.onclick = function() {
    //     oImg.style.display = 'none'
    //     getData()
    //     oTxt.value = ''
    // }

    oBtn.onclick = function() {
        oImg.style.display = 'none'
        oList.innerHTML += `
                        <li>
                            <img src="https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTKpmpnxfYeeUh1v7wLebKp4kQB0bt1DoUchEibyNMm4uRcMZCskF2kK2doK96boJyDmBtqBIXvmLaA/132" alt=""> 
                            <p>peak</p>
                            <span class="return">-> 回复</span>
                            <span class="delete">X 删除</span>
                            <span class="time">${year + '年' + month + '月' + day + '日' + toDou(h) + ':' + toDou(m) + ':' + toDou(s)}</span>
                            <b>${oTxt.value}</b>
                        </li>
                    `
        oTxt.value = '' 
    }
    oList.onclick = function(e) {
        if(e.target.tagName === 'SPAN') {
            e.target.parentNode.remove()
        }
    }


}


// 返回顶部
{
    let oTop = document.querySelector('.returnTop')
    // var timer = null
    oTop.onclick = function () {
        clearInterval(timer)
        timer = setInterval(function () {
            document.documentElement.scrollTop -= 40
            // 如果滚动条到头了，清除定时器
            if (document.documentElement.scrollTop === 0) {
                clearInterval(timer)
            }
        }, 5)
    }
    document.onmousewheel = function () {
        // 页面触发滚动条把定时器停止
        clearInterval(timer)
    }
    window.onscroll = function () {
        if (document.documentElement.scrollTop >= 100) {
                oTop.style.display = 'block'
               
        }else if (document.documentElement.scrollTop < 100){
               
                oTop.style.display = 'none'
                
        }
    }
}

// 中间内容部分
{
    let id = JSON.parse(localStorage.getItem('id'))
    console.log(id)
    let oContent = document.querySelector('.content')
    ajax({
        url:'http://192.168.10.28:8080//qfBlog/getBlogAndComment',
        type:'get',
        data:{
            id:id
        },
        success(res) {
            let json = JSON.parse(res)
            console.log(json)
            oContent.innerHTML = ` <p>${json.data[0].title}</p>
            <div class="txt">${json.data[0].content}</div>`
        }

    })
}
